#ifndef _SN_CONFIG_H
#define _SN_CONFIG_H

#include "basic.h"
#include "hardware_config.h"
#include "hal_config.h"
#define FLASH_MAGIC_VALUE  0x55 
#define FLASH_PAGE_SIZE 1024 //??
#define FLASH_PAGE_NUM  1 //1?
typedef int32_t  sn_err_t;

#define SN_OK           0       /*!< esp_err_t value indicating success (no error) */
#define SN_FAIL        -1      /*!< Generic esp_err_t code indicating failure */

/**
 * @brief can???? 
 * 
 */
#define CAN_BROADCAST_ADDR          0x01      /*!< ????*/  
#define CAN_MASTER_ADDR             0x03   /*!< ????*/
#define CAN_MASTER_PROBE_ADDR       0x02   /*!< ??????*/

#define CAN_TIMEOUT_VALUE 10  //10/2 5s
/**
 * @brief 主机下发的设置命令
 * 
 */
/*广播命令 配合广播地址使用*/
#define CAN_CMD_BROADCAST_HOST_SET_VOUT     0x00 /*!<主机广播设置电压  */
#define CAN_CMD_BROADCAST_HOST_SET_IOUT     0x01 /*!<主机广播设置电流  */
#define CAN_CMD_BROADCAST_HOST_SET_DEV      0x02 /*!<主机广播设置开关机  */
/*单机命令*/
#define CAN_CMD_DEVICE_HOST_SET_VOUT               0x00    /*!< 设置电压 电流*/
#define CAN_CMD_DEVICE_HOST_SET_DEV_POWER          0x01    /*!< 设置开关机*/
#define CAN_CMD_DEVICE_HOST_GET_MOD_NUM            0x02
#define CAN_CMD_DEVICE_HOST_GET_MOD_STATUS         0x03
#define CAN_CMD_DEVICE_HOST_GET_MOD_AC_VOUT        0x04
#define CAN_CMD_DEVICE_HOST_GET_MOD_VOUT_IOUT      0x05

#define MAX_MODULE_COUNT 2 //最大模块数
#define MOD_AVERAGE_THRESHOLD   1 //模块均流阈值范围
#define MOD_SETTING_STEP 1 // 模块电压操作一次的值
#define CAN_LOOP_TIEMR 50
union ufloat_cons_t {
 float fval;
 char farray[4];
};

#endif // !_SN_CONFIG_H
